package top.ysez.product.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import top.ysez.product.dao.ProductDao;
import top.ysez.product.entity.Product;
import top.ysez.product.service.ProductService;

import java.util.List;

/**
 * 实现类
 *
 * @author YsEz
 * @version V1.0.0
 * @date 2022/6/3 13:22
 */
@Service
public class ProductServiceImpl implements ProductService {
    @Autowired
    private ProductDao productDao;

    @Override
    public Product findById(Long id) {
        return productDao.findById(id).get();
    }

    @Override
    public void saveProduct(Product product) {
        productDao.save(product);
    }

    @Override
    public void updateProduct(Product product) {
        productDao.save(product);
    }

    @Override
    public void deleteProduct(Long id) {
        productDao.deleteById(id);
    }

    @Override
    public List<Product> findAll() {
        return productDao.findAll();
    }
}
